package com.lkd.handler;

import com.lkd.business.MsgHandler;
import com.lkd.contract.SupplyContract;
import com.lkd.service.VendingMachineService;
import com.lkd.utils.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.IOException;

public class SupplyMsgHandler implements MsgHandler {

    @Autowired
    private VendingMachineService vendingMachineService;

    @Override
    public void process(String jsonMsg) throws IOException {
        SupplyContract byJson = JsonUtil.getByJson(jsonMsg, SupplyContract.class);
        if (byJson==null)return;
        vendingMachineService.supply(byJson);
    }
}
